//
//  ActivityDetailViewController.m
//  UI-豆瓣项目APP
//
//  Created by dllo on 15/9/9.
//  Copyright (c) 2015年 孙鹏. All rights reserved.
//

#import "ActivityDetailViewController.h"
#import "ActivityDetailView.h"
#import "CollectActivity.h"
@interface ActivityDetailViewController ()

@end

@implementation ActivityDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = self.activityVC.title;
    UIImage *rightImage = [UIImage imageNamed:@"btn_nav_share.png"];
    rightImage = [rightImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithImage:rightImage style:UIBarButtonItemStyleDone target:self action:@selector(shareAction)];
    UIImage *leftImage = [UIImage imageNamed:@"btn_nav_back.png"];
    leftImage = [leftImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithImage:leftImage style:UIBarButtonItemStyleDone target:self action:@selector(backAction)];
    self.view.backgroundColor = [UIColor redColor];
    
    UIScrollView *scrollV = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0,375, 667-60)];
    scrollV.backgroundColor = [UIColor whiteColor];
    scrollV.contentSize = CGSizeMake(375, 667*3);
    scrollV.bounces = NO;
    
    ActivityDetailView *activityV = [[ActivityDetailView alloc]initWithFrame:CGRectMake(0, 0, 375, 667*3)];
    activityV.backgroundColor = [UIColor whiteColor];
    activityV.activityV = self.activityVC;
    [activityV getValueHeight:^(CGFloat Height) {
        scrollV.contentSize =CGSizeMake(375, Height+250);
    }];
//    NSLog(@"acti == %@",self.activityVC.title);
//    NSLog(@"acti2 == %@",activityV.activityV.title);
    [self.view addSubview:scrollV];
    [scrollV addSubview:activityV];
    [activityV release];
}

-(void)shareAction{
    NSLog(@"share");
    Activitylist *activity = [Activitylist new];
    activity = self.activityVC;
    NSString*userName = [[NSUserDefaults standardUserDefaults]objectForKey:@"LoginName"];
//    NSLog(@"acyivity == %@",activity.act.name);
//    NSLog(@"userName == %@",userName);
    [[CollectActivity shareDataBase]insertActivity:activity userName:userName];
}
-(void)backAction{
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
